#定义定点数转浮点数
def fix2float(v ):
    b = int(v,16)   #receive v for 16 hex
    din = float(b)    #int to float
    x = din / pow(2,16)#din >> 16
    return format(x,'.4f')

# 从txt文件加载数据
with open('fxp_out.txt', 'r') as file:
    lines = file.readlines()

output_lines = []

# 拆分每一行的数字
for line in lines:
    numbers = line.strip()
    f = str(fix2float(numbers))
    output_lines.append(f)

merged_lines = []
for i in range(0, len(output_lines), 2):
    merged_line = f'({output_lines[i].strip()}, {output_lines[i+1].strip()})'
    merged_lines.append(merged_line)

# 将结果写回文件
with open('float_out.txt', 'w') as file:
    for line in merged_lines:
        file.write(line + '\n')
